package edu.ntu.cloudroid.xacml.obligation;

import java.util.ArrayList;
import java.util.List;


import com.sun.xacml.Obligation;
import com.sun.xacml.ctx.RequestCtx;

import edu.ntu.cloudroid.model.data.DetachedData;
import edu.ntu.cloudroid.model.profile.ProfileData;
import edu.ntu.cloudroid.server.backendservice.DataService;

/**
 * @author ttadinh
 * Always return the latest data
 */
public class DefaultObligation implements ObligationHandle{

	@Override
	public List<DetachedData> processObligation(ProfileData subject,
			ProfileData resource, RequestCtx requestCtx, Obligation o)
			throws Exception {
		List<DetachedData> list = new ArrayList<DetachedData>();
		
		list.add(DataService.getLatestData(resource, resource.getDataId()).detach(-1));
		return list;
	}

}
